﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using Micronet.OpenWeb.Com.BLL;
using Micronet.OpenWeb.Com.Controls;
using Micronet.OpenWeb.Common;
using Micronet.OpenWeb.Utils;
using Telerik.Web.UI;

namespace Micronet.OpenWeb.OpenWeb.Admin.Views.Shared.Blog
{
    public partial class UserInBlogFriendGroupEdit : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (OwConstants.QueryString.ID.OwQsIsExist())
            {
                UserInFriendGroupEditDv.DefaultMode = DetailsViewMode.Edit;
            }
            else
            {
                UserInFriendGroupEditDv.DefaultMode = DetailsViewMode.Insert;
            }
        }
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            UserInFriendGroupEditDv.DataBound += new EventHandler(UserInFriendGroupEditDv_DataBound);
        }
        protected void UserInFriendGroupEditDv_DataBound(object sender, EventArgs e)
        {
            //if (UserInFriendGroupEditDv.CurrentMode == DetailsViewMode.Edit)
            //{
            //    OwComboBox UserNameCbb = (OwComboBox)UserInFriendGroupEditDv.FindControl("UserNameCbb");

            //    MembershipUserCollection users = Membership.GetAllUsers();
            //    foreach (MembershipUser user in users)
            //    {
            //        UserNameCbb.Items.Add(new RadComboBoxItem(user.UserName, user.ProviderUserKey.ToString()));
            //    }
            //    UserNameCbb.DataBind();
            //}

        }

        protected void UserNameCbb_OnInit(object sender, EventArgs e)
        {
            //if (UserInFriendGroupEditDv.CurrentMode == DetailsViewMode.Edit || UserInFriendGroupEditDv.CurrentMode == DetailsViewMode.Insert)
            //{
            //OwComboBox UserNameCbb = (OwComboBox)UserInFriendGroupEditDv.FindControl("UserNameCbb");
            OwComboBox UserNameCbb = sender as OwComboBox;
            //UserNameCbb.Init += new EventHandler(UserNameCbb_Init);
            //UserNameCbb.DataSource = Membership.GetAllUsers();
            MembershipUserCollection users = Membership.GetAllUsers();
            foreach (MembershipUser user in users)
            {
                UserNameCbb.Items.Add(new RadComboBoxItem(user.UserName, user.ProviderUserKey.ToString()));
            }
            UserNameCbb.DataBind();

            //}
        }


    }
}